﻿using System;
using System.Net.Mail;

namespace easy_ccms.core
{
   public class Mailer
   {

       /// <summary>
       /// Send notify email to cpo@fssoftware.cz and passing data
       /// async option to make supre it is fast, however does not check for status message(if it was recieved or not)
       /// </summary>
       /// <param name="emSubject">The em subject.</param>
       /// <param name="emBody">The em body.</param>
       /// <param name="toEmail">To email.</param>
       /// <param name="isHtmlEncoded">if set to <c>true</c> [is HTML encoded].</param>
       /// <param name="enableSsl">if set to <c>true</c> [enable SSL].</param>
       /// <returns></returns>
       protected static Boolean SendMail(string emSubject, string emBody, string toEmail = null, bool isHtmlEncoded = true, bool enableSsl = false)
       {

           ////Log.LogErrorMessage(string.Format("Subject: {0} \r\n Body: {1}", emSubject, emBody), "Mailer");


           //if (toEmail == null) toEmail = NudaJeFuc.WebUI.Properties.Settings.Default.adminEmail;
           //MailAddress from = new MailAddress(NudaJeFuc.WebUI.Properties.Settings.Default.SystemEmailAddress,
           //                                   NudaJeFuc.WebUI.Properties.Settings.Default.SystemEmailAddressName,
           //                                   System.Text.Encoding.UTF8);
           //MailAddress to = new MailAddress(toEmail);
           //MailMessage message = new MailMessage(from, to);

           //try
           //{

           //    SmtpClient client = new SmtpClient(NudaJeFuc.WebUI.Properties.Settings.Default.mailSmtpServer,
           //                                        NudaJeFuc.WebUI.Properties.Settings.Default.mailSmtpServerPort);
           //    client.EnableSsl = enableSsl;

           //    client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
           //    client.Credentials = new System.Net.NetworkCredential(NudaJeFuc.WebUI.Properties.Settings.Default.mailUserName,
           //                                                          NudaJeFuc.WebUI.Properties.Settings.Default.mailUserPassword);


           //    message.Subject = emSubject;
           //    message.SubjectEncoding = System.Text.Encoding.UTF8;
           //    message.Body = emBody;
           //    message.BodyEncoding = System.Text.Encoding.UTF8;
           //    message.IsBodyHtml = isHtmlEncoded;

           //    client.Send(message);
           //    return true;
           //}
           //catch (System.Net.Mail.SmtpException ex)
           //{
           //    string error = ex.ToString();
           //    return false;
           //}
           return false;
       }
      ~Mailer(){
      
      }
   }
}